package com.hotel.mapper;

import com.hotel.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    /**测试*/
    @Select("select * from user")
    List<User> findAll();
    /**登录*/
    @Select("select u.user_id,u.user_name,u.password from user u where user_name = #{userName} and password = #{password} and sort_num=#{value}")
    User findUserByUP(User user);
    /**分页*/
    @Select("select count(1) from user where sort_num!=3")
    Long getTotal();

    List<User> findEmpListByPage(@Param("start") int start,
                                  @Param("size")int size,
                                  @Param("query")String query);

    @Select("select u.user_id, u.user_name,u.sex,u.phone,u.number from user u where user_id=#{userId}")
    User findEmpById(Integer id);

    @Delete("delete from user where user_id=#{userId}")
    void delete(Integer userId);

    void addEmp(User user);

    @Update("update user set phone=#{phone} where user_id=#{userId}")
    void updateEmp(User user);

    void addUser(User user);

    @Update("update user set status=#{status} where user_id=#{userId}")
    void updateStatus(User user);
}
